package com.lancoo.answer.widget.combinationView;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.lancoo.answer.R;
import com.lancoo.answer.model.ConstantBean;
import com.lancoo.answer.model.entity.AnswerSheetBean;
import com.lancoo.answer.model.entity.TaskControlBean;
import com.lancoo.answer.ui.answerSheet.AnswerSheetAdapter;

import java.util.List;

/**
 * Created by pengmi on 2022/2/22 16:49
 * Description:考试答题卡组合view
 */
public class CompositionTestAnswerSheetView extends RelativeLayout {


    public CompositionTestAnswerSheetView(@NonNull Context context) {
        super(context);
        init(context);
    }

    public CompositionTestAnswerSheetView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public CompositionTestAnswerSheetView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }


    private void init(Context context){
        LayoutInflater.from(context).inflate(R.layout.ev_view_test_answer_sheet_composition,this);
    }

    public void setData(List<AnswerSheetBean> answerSheetBeanList){
        TestRequirementView tqv_head=findViewById(R.id.tqv_head);
        tqv_head.setData();
        RecyclerView recyclerView = findViewById(R.id.recycler_view);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        TaskControlBean taskControlBean= ConstantBean.Companion.getTaskControlBean();
        int trainSence=0;
        if(taskControlBean!=null){
            trainSence = taskControlBean.getTrainSence();
            int paperType = taskControlBean.getPaperType();
            if(paperType==2){
                trainSence=1;
            }
        }
        AnswerSheetAdapter mAdapter=new AnswerSheetAdapter(answerSheetBeanList,trainSence);
        recyclerView.setAdapter(mAdapter);
    }
}
